﻿
using System.Data.SqlClient;
using com.loto.Common.DBUtility;
using System;
using System.Collections.Generic;
namespace com.huigo.Framework.BLL
{
    public class InvoiceOrderFlow
    {
        public static bool AddOrderFlow(long orderID, long operFID, int statusId, string statusMemo, SqlTransaction trans)
        {
            Model.InvoiceOrderFlow orderFlow = new Model.InvoiceOrderFlow();
            orderFlow.FlowOrderFid = orderID;
            orderFlow.FlowOperFid = operFID;
            orderFlow.FlowOrderStatusFid = statusId;
            orderFlow.FlowMemo = statusMemo;
            return SqlServerDal.InvoiceOrderFlow.Insert(orderFlow, trans);
        }
        public static List<Model.InvoiceOrderFlow> GetInvoiceOrderFlowList(long orderFid)
        {
            List<string> fields = new List<string>() 
             {
                "FLOW_ID",
                "FLOW_ORDER_FID",
                "FLOW_ORDER_STATUS_FID",
                "FLOW_CREATED_ON",
                "FLOW_MEMO,USER_NAME,STATUS_DESC"
             };
            List<WhereStatement> whereList = new List<WhereStatement>();
            whereList.Add(new WhereStatement("FLOW_ORDER_FID", "=", orderFid.ToString(), ""));
            List<JoinStatement> join = new List<JoinStatement>();
            join.Add(new JoinStatement("inner", "HG_INVOICE_ORDER_STATUS", "STATUS_ID=FLOW_ORDER_STATUS_FID"));
            join.Add(new JoinStatement("left", "HG_USER_INFO", "FLOW_OPER_FID=USER_ID"));
            List<OrderByStatement> order = new List<OrderByStatement>();
            order.Add(new OrderByStatement("FLOW_CREATED_ON",false));
            List<Model.InvoiceOrderFlow> PolicyFlowList = null;
            PolicyFlowList = SqlServerDal.InvoiceOrderFlow.GetItems(fields, join, whereList, order, null);
            return PolicyFlowList;

        }
        public static bool AddInvoiceOrderFlow(long orderFid, long operFID, int statusId, string statusMeno, SqlTransaction trans)
        {

            Model.InvoiceOrderFlow InvoiceOrderFlow = new Model.InvoiceOrderFlow();
            InvoiceOrderFlow.FlowCreatedOn = DateTime.Now;
            InvoiceOrderFlow.FlowMemo = statusMeno;
            InvoiceOrderFlow.FlowOperFid = operFID;
            InvoiceOrderFlow.FlowOrderFid = orderFid;
            InvoiceOrderFlow.FlowOrderStatusFid = statusId;
            return SqlServerDal.InvoiceOrderFlow.Insert(InvoiceOrderFlow, trans);
        }
    }
}
